package com.xbongbong.crm.perform.query.render.insert;

import com.xbongbong.crm.abstracts.AbstractCrmNewPageRenderService;
import com.xbongbong.crm.help.FineClueHelp;
import com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt;
import com.xbongbong.paas.enums.PlatFormEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.dto.FormDataAddGetDTO;
import com.xbongbong.paas.pojo.vo.FormDataAddGetVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.enums.FineClueEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author: yingjf
 * @date: 2022/9/15 16:49
 * @description: 竞争对手 新建 页面渲染
 */
@Service("competitorNewPageRenderServiceImpl")
public class CompetitorNewPageRenderServiceImpl extends AbstractCrmNewPageRenderService {
    @Resource
    private FineClueHelp fineClueHelp;


    @Override
    public List<Integer> businessType() {
        return Arrays.asList(XbbRefTypeEnum.COMPETITOR.getCode());
    }

    @Override
    public void businessHandleExplain(FormDataAddGetDTO formDataAddGetDTO, List<FieldAttrEntity> list, PaasFormEntityExt form) throws XbbException {

    }

    @Override
    public void formatSaasAttrToReturn(FormDataAddGetDTO formDataAddGetDTO, FormDataAddGetVO formDataAddGetVO, PaasFormEntityExt paasFormEntityExt) throws XbbException {
        // 查看是否能使用精线索的工商查询
        String corpid = formDataAddGetDTO.getCorpid();
        if (fineClueHelp.fineClueUsable(corpid, FineClueEnum.BUSINESS) ) {
            formDataAddGetVO.setIsFineClue(1);
        }
        formDataAddGetVO.setPaasFormEntity(paasFormEntityExt);
    }
}
